dd uma imagem, mas recebendo apenas uma fração do espaço no meu cartão SD

2

Eu baixei uma imagem do Ubuntu Linaro. Então eu coloco a imagem em um cartão SD de 32GB da seguinte forma:

sudo dd bs=4M if=ubuntu-14.04-hdmi-z7010-20140611.img of=/dev/mmcblk0

Funciona bem, eu posso inicializar a partir dele, etc. No entanto, o sistema de arquivos diz que eu tenho muito menos espaço que o tamanho de 32GB do cartão SD:

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:~> 

Existe uma maneira de dizer ao dd, copiar esta imagem para o cartão SD, mas formatar e usar toda a unidade?

    
por Ivan 03.07.2015 / 02:05

1 resposta

0

(Esta é a solução do OP. Foi originalmente publicada como uma edição da questão.)

Usando as instruções dos comentários, consegui redimensionar a partição. Foi um pouco confuso no começo, mas acho que entendi:

[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

Montando o cartão SD e depois

[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
    
por 12.12.2017 / 07:15

Tags