1

I'm trying to copy the single partition /dev/sda1 to /dev/sdc1, but I'm getting the error "no space left on device" and I honestly don't get why.

I'm working on an Oracle Cloud Infrastructure (OCI) VM where /dev/sda is a 768 GB volume whose sda1 partition has been shrinked o just 32 GB (the process was ok, no data loss! I can guarantee because that volume is an Oracle Database ASM disk group, and everything works fine after shrinking).

Since OCI allows only to grow volume size, I created a new volume /dev/sdc sized 50 GB (that's the minimum size allowed) and created a partition /dev/sdc1 of just 32 GB (same size as /dev/sda1).

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdc      8:32   0    50G  0 disk
└─sdc1   8:33   0    32G  0 part
sda      8:0    0   768G  0 disk
└─sda1   8:1    0    32G  0 part

I get an error while running

# dd if=/dev/sda1 of=/dev/sdc1 bs=512b conv=noerror,sync
dd: error writing ‘/dev/sdc1’: No space left on device
22567+0 records in
22566+0 records out
5915787264 bytes (5.9 GB) copied, 42.9384 s, 138 MB/s

The two partitions are exactly the same size, as shown by fdisk

# fdisk /dev/sda

Disk /dev/sda: 824.6 GB, 824633720832 bytes, 1610612736 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0x7c9bf84b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    67108863    33553408   83  Linux


# fdisk /dev/sdc
Disk /dev/sdc: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0x9b11add5

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    67108863    33553408   83  Linux

What am I doing wrong?

  • It errors out quite early compared to 32G, I would verify nodes `ls -l /dev/sd?1` verify node numbers with `lsblk -b`, check `dmesg` for any messages, use `dd_rescue` or `ddrescue` instead. – NiKiZe Aug 27 '21 at 11:45

2 Answers2

0

I don't know what the problem was, but I had it work just cloning the entire volume

# dd if=/dev/sda of=/dev/sdc bs=512b conv=noerror,sync

Of course, the operation stops at 50 GB that is /dev/sdc total size erroring the same message, but the outcome is OK.

  • 2
    What was maybe the problem: your system didn't update its in-memory partition tables. You probably created /dev/dc1 at ~ 6G and increased it later. The easiest tool to force such update is `kpartx -u ...`. This should happen only if the partition is in use though. – A.B Aug 27 '21 at 16:18
-2

What was wrong is the notation of the partition number in the original command:

dd if=/dev/sda1 of=/dev/sdc1 bs=512b conv=noerror,sync

should only indicate the device value letter not the the number for dd to work correctly:

dd if=/dev/sda of=/dev/sdc bs=512b conv=noerror,sync

I'm not sure if dd is what you need for your goal.

vidarlo
  • 6,654
  • 2
  • 18
  • 31
Gustav
  • 1