我下载了 Ubuntu Linaro 的镜像。然后我将镜像添加到 32GB 的 SD 卡上,如下所示:
sudo dd bs=4M if=ubuntu-14.04-hdmi-z7010-20140611.img of=/dev/mmcblk0
运行良好,我可以从它启动等等。但是,文件系统显示我的空间比 SD 卡的 32GB 大小小得多:
linaro-nano:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 6.7G 6.3G 12K 100% /
devtmpfs 465M 4.0K 465M 1% /dev
none 97M 372K 97M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 485M 0 485M 0% /run/shm
none 100M 0 100M 0% /run/user
linaro-nano:~>
有没有办法告诉 dd,将此图像复制到 SD 卡,但格式化并使用整个驱动器?
答案1
(这是 OP 的解决方案。它最初是作为问题的编辑发布的。)
使用评论中的说明,我能够调整分区大小。一开始有点困惑,但我想我明白了:
[idf@localhost ~]$ sudo fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/mmcblk0: 29.7 GiB, 31914983424 bytes, 62333952 sectors
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: 0x000a07b6
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 264191 262144 128M b W95 FAT32
/dev/mmcblk0p2 264192 62333951 62069760 29.6G 83 Linux
Command (m for help): d
Partition number (1,2, default 2):
Partition 2 has been deleted.
Command (m for help): p
Disk /dev/mmcblk0: 29.7 GiB, 31914983424 bytes, 62333952 sectors
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: 0x000a07b6
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 264191 262144 128M b W95 FAT32
Command (m for help): w
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 264191 262144 128M b W95 FAT32
[idf@localhost ~]$ sudo fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
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):
First sector (264192-62333951, default 264192):
Last sector, +sectors or +size{K,M,G,T,P} (264192-62333951, default 62333951):
Created a new partition 2 of type 'Linux' and of size 29.6 GiB.
Command (m for help): p
Disk /dev/mmcblk0: 29.7 GiB, 31914983424 bytes, 62333952 sectors
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: 0x000a07b6
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 264191 262144 128M b W95 FAT32
/dev/mmcblk0p2 264192 62333951 62069760 29.6G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[idf@localhost ~]$ sudo e2fsck -f /dev/mmcblk0p2
e2fsck 1.42.12 (29-Aug-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
rootfs: 120773/448800 files (0.2% non-contiguous), 980314/1792000 blocks
[idf@localhost ~]$ sudo resize2fs /dev/mmcblk0p
mmcblk0p1 mmcblk0p2
[idf@localhost ~]$ sudo resize2fs /dev/mmcblk0p
mmcblk0p1 mmcblk0p2
[idf@localhost ~]$ sudo resize2fs /dev/mmcblk0p
mmcblk0p1 mmcblk0p2
[idf@localhost ~]$ sudo resize2fs /dev/mmcblk0p2
resize2fs 1.42.12 (29-Aug-2014)
Resizing the filesystem on /dev/mmcblk0p2 to 7758720 (4k) blocks.
The filesystem on /dev/mmcblk0p2 is now 7758720 (4k) blocks long.
[idf@localhost ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.9G 0 2.9G 0% /dev
tmpfs 2.9G 72M 2.8G 3% /dev/shm
tmpfs 2.9G 980K 2.9G 1% /run
tmpfs 2.9G 0 2.9G 0% /sys/fs/cgroup
/dev/mapper/fedora-root 50G 20G 28G 42% /
tmpfs 2.9G 40K 2.9G 1% /tmp
/dev/sda5 477M 141M 307M 32% /boot
/dev/mapper/fedora-home 396G 68G 309G 18% /home
/dev/sda4 200M 9.6M 191M 5% /boot/efi
tmpfs 585M 20K 585M 1% /run/user/1000
安装 SD 卡,然后
[idf@localhost ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.9G 0 2.9G 0% /dev
tmpfs 2.9G 72M 2.8G 3% /dev/shm
tmpfs 2.9G 988K 2.9G 1% /run
tmpfs 2.9G 0 2.9G 0% /sys/fs/cgroup
/dev/mapper/fedora-root 50G 20G 28G 42% /
tmpfs 2.9G 40K 2.9G 1% /tmp
/dev/sda5 477M 141M 307M 32% /boot
/dev/mapper/fedora-home 396G 68G 309G 18% /home
/dev/sda4 200M 9.6M 191M 5% /boot/efi
tmpfs 585M 20K 585M 1% /run/user/1000
/dev/mmcblk0p1 127M 6.3M 120M 5% /run/media/idf/BOOT
/dev/mmcblk0p2 30G 3.6G 25G 13% /run/media/idf/rootfs