100MBパーティションに約38MBのファイルを書きたいです。ただし、パーティションをディレクトリにマウントすると、そのパーティションは/dev/loop0
代わりにマウントされます/dev/sdc1
(例では)。
mv
これは、コマンドでデバイスに38MBのファイルをすべて書き込むことができないため、問題になるようです。私がしたことは次のとおりです(以下は私のユースケースですが、これが関連しているかどうかはわかりません)。ラズベリーパイ3):
[slife pi]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): o
Created a new DOS disklabel with disk identifier 0x2ec21fb4.
Command (m for help): p
Disk /dev/sdc: 29.83 GiB, 32010928128 bytes, 62521344 sectors
Disk model: Card Reader
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2ec21fb4
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-62521343, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-62521343, default 62521343): +100M
Created a new partition 1 of type 'Linux' and of size 100 MiB.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (206848-62521343, default 206848):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (206848-62521343, default 62521343):
Created a new partition 2 of type 'Linux' and of size 29.7 GiB.
Partition #2 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: y
The signature will be removed by a write command.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[slife pi]# mkfs.vfat /dev/sdc1
mkfs.fat 4.1 (2017-01-24)
[slife pi]# ls
ArchLinuxARM-rpi-latest.tar.gz ArchLinuxARM-rpi-latest.tar.gz.1 boot root unzipped
[slife pi]# mount /dev/sdc1 boot
[slife pi]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 10M 0 loop /mnt/pi/boot
sda 8:0 0 1.8T 0 disk
├─sda1 8:1 0 260M 0 part
├─sda2 8:2 0 16M 0 part
├─sda3 8:3 0 1.3T 0 part
├─sda4 8:4 0 873M 0 part
├─sda5 8:5 0 16G 0 part [SWAP]
├─sda6 8:6 0 512M 0 part /boot/EFI
└─sda7 8:7 0 570.2G 0 part /
sdc 8:32 1 29.8G 0 disk
├─sdc1 8:33 1 100M 0 part
└─sdc2 8:34 1 29.7G 0 part
sr0 11:0 1 1024M 0 rom
[slife pi]# mkfs.ext4 /dev/sdc2
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 7789312 4k blocks and 1949696 inodes
Filesystem UUID: e4033af0-dd50-4286-abc4-ea6982b21439
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[slife pi]# mount /dev/sdc2 root
[slife pi]# bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
[slife pi]# sync
[slife pi]# mv root/boot/* boot
mv: error writing 'boot/kernel7.img': No space left on device
mv: cannot create directory 'boot/overlays': No space left on device
mv: error writing 'boot/start4cd.elf': No space left on device
mv: error writing 'boot/start4db.elf': No space left on device
mv: error writing 'boot/start4.elf': No space left on device
mv: error writing 'boot/start4x.elf': No space left on device
mv: error writing 'boot/start_cd.elf': No space left on device
mv: error writing 'boot/start_db.elf': No space left on device
mv: error writing 'boot/start.elf': No space left on device
mv: error writing 'boot/start_x.elf': No space left on device
ご覧のとおり、mount /dev/sdc1 boot
コマンドの後に/dev/loop0
代わりにインストールされました/dev/sdc1
。その結果、これを実行したときに多くのファイルがmv root/boot/* boot
返されました。No space left on device
では、これらのファイルをどのように正しく移動できますか/dev/sdc1
?
以下はディレクトリのサイズを示すdu
呼び出しですroot/boot
(参考に「unzipped」というディレクトリにローカルで内容を解凍しました)。
[slife unzipped]# du boot
940 boot/overlays
38776 boot
[slife unzipped]# du -h boot
940K boot/overlays
38M boot
/dev/sdc1
編集(フルパスを明確にするため):to/mnt/pi/boot
と
/dev/sdc2
toをインストールしようとしています/mnt/pi/root
(これは成功しました)。
編集2:出力 df -i /dev/sdc1
Filesystem Inodes IUsed IFree IUse% Mounted on
dev 2024406 546 2023860 1% /dev
編集3:@telcoMが要求したコマンドの出力:
slife: ~ » losetup -l -a
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
/dev/loop0 0 0 1 0 /dev/sdc1 0 512
slife: ~ » ls -l /dev/sdc1
-rw-r--r-- 1 root root 10485760 Dec 30 12:49 /dev/sdc1
ベストアンサー1
デバイス/dev/sdc1
ノードは通常の10Mファイルに置き換えられ、10Mパーティションイメージファイルとして機能します。これは、いくつかの以前のコマンドのエラーが原因で発生する可能性があります。
まず、ファイルを削除します。
umount /mnt/pi/boot
losetup -l -a
## if the output of the losetup command above is not empty, run this command:
losetup -r /dev/loop0
その後、画像ファイルを横に移動します。
mv /dev/sdc1 /tmp/sdc1-image-10M.ima
(おそらくこのファイルは役に立たないようですので削除しても構いませんが、後悔するより安全性が優れています...)
これを実際のブロックデバイスノードに置き換えて(必要に応じて)権限を設定します。これはmknod
、最新のシステムでこのコマンドを使用するいくつかの理由の1つです。
mknod /dev/sdc1 b 8 33
chown root:disk /dev/sdc1
chmod 660 /dev/sdc1
mknodコマンドのパラメータは次のとおりです。
- 作成するデバイスの名前
- デバイスタイプ:
b
=ブロックデバイス、c
=文字デバイス。 - 主な装置番号:
lsblk
出力からsdc1
- マイナー番号:また
lsblk
出力からsdc1
Accessは、/dev/sdc1
予期しないイメージファイルではなく物理パーティションを再提供する必要があります。元mkfs.vfat
のコマンドは実際のパーティションではなくイメージファイルに影響を与えるため、これをやり直す必要があります。
mkfs.vfat /dev/sdc1
mount /dev/sdc1 /mnt/pi/boot
その後、次のことを続行できます。
mv /mnt/pi/root/boot/* /mnt/pi/boot
(わかりやすくするためにフルパスを使用しています。もちろん、必要に応じて現在のディレクトリよりも短いパスを使用することもできます。)