2

I am trying to create a Live USB using the dd utility. The first thing I did was wipe the USB using the following command:

~ $ dd if=/dev/zero of=/dev/sdb bs=512 count=1

The 8GB USB has a total memory of 7.6GB, as told by using the command.

~ $ fdisk -l
...
Disk /dev/sdb: 7.6 GiB, 8097103872 bytes, 15814656 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

The problem is that after perform the "dd" operation to write the ISO to the USB, the partitions to not take up the entire disk space.

I run this command which generates the succeeding output.

~ $ sudo dd if=kali-linux-2016.2-amd64.iso of=/dev/sdb bs=1M

2934+1 records in
2934+1 records out
3076767744 bytes (3.1 GB, 2.9 GiB) copied, 395.581 s, 7.8 MB/s

I then run the fdisk command again which generates this output.

Disk /dev/sdb: 7.6 GiB, 8097103872 bytes, 15814656 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: 0x77e6cfe3

Device     Boot   Start     End Sectors  Size Id Type
/dev/sdb1  *         64 5794271 5794208  2.8G 17 Hidden HPFS/NTFS
/dev/sdb2       5794272 6009311  215040  105M  1 FAT12

Note how the top line indicates 7.6GiB of memory but the partitions only take up 2.8GB and 105M respectively. Even when I analyse the partitions in gparted it only shows these two partitions and does not list any extra space on the USB stick.

Is there something I'm missing here?

UPDATE
I was wrong in my assumption of there being no space left on the device. I have answered my question below with the commands I used to make use of the remaining space on the disk.

  • 1
    dd only copies raw data. You expect that data to have magically changed, into a different partition table, different filesystem, ... for making such changes you need parted, resize2fs, and so on. – frostschutz Oct 12 '16 at 14:09
1

The dd utility reads and writes blocks, with no regard to the contents of those blocks; it's operating at a lower level than partitions. In this case, you're writing an image, and that image only contains two partitions with a fixed size. There are only about 2.9GB worth of blocks, so your larger disk gets just those blocks written to it.

There's a decent article on how the partition table works at http://wiki.osdev.org/Partition_Table, among other places. The short version is that the table lists the beginning of each partition and how large each one is.

0

So it turns out the space was there but was just not showing up in gparted.

For any future users, here is the series of commands I used to utilise the extra space.

~ $ parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) print devices
/dev/sda (128GB)
/dev/sdb (8097MB)

(parted) select /dev/sdb                                                
Using /dev/sdb

(parted) print                                                          
Model: hp v195b (scsi)
Disk /dev/sdb: 8097MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      32.8kB  2967MB  2967MB  primary               boot, hidden
 2      2967MB  3077MB  110MB   primary  fat16

(parted) mkpart primary 3077 7500       

(parted) quit                                                            
Information: You may need to update /etc/fstab.

To confirm:

~ $ fdisk -l
...
Disk /dev/sdb: 7.6 GiB, 8097103872 bytes, 15814656 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: 0x77e6cfe3

Device     Boot   Start      End Sectors  Size Id Type
/dev/sdb1  *         64  5794271 5794208  2.8G 17 Hidden HPFS/NTFS
/dev/sdb2       5794272  6009311  215040  105M  1 FAT12
/dev/sdb3       6009312 14648437 8639126  4.1G 83 Linux
0

While you may have enough space there should be other separate partitions that may be giving you issues. Refresh gpart and check all partitions to be positive that isnt part of the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.