creating disk image using dd to external drive getting error: Not a directory

Asked by Bart Opiola on 2011-09-09

root@ubuntu:~# sudo fdisk -l

Disk /dev/sda: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6f048d9e

   Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 102400 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 13 77826 625027072 7 HPFS/NTFS

Disk /dev/sdb: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00017007

   Device Boot Start End Blocks Id System
/dev/sdb1 1 91202 732572672 b W95 FAT32
root@ubuntu:~# dd if=/dev/sda of=/dev/sdb1/images/Win7Ubuntu.img
dd: opening `/dev/sdb1/images/Win7Ubuntu.img': Not a directory
root@ubuntu:~# dd if=/dev/sda of=/dev/sdb1/Win7ubuntu.img bs=32M conv=notrunc
dd: opening `/dev/sdb1/Win7ubuntu.img': Not a directory
root@ubuntu:~# dd if=/dev/sda of=/dev/sdb1/images bs=32M conv=notrunc
dd: opening `/dev/sdb1/images': Not a directory

1.I am a windows user trying to convert to linux. I am trying to create a HDD image and save it to my external.
2.I am using ubuntu live cd
3.I have tried running with out bs=32M - with no luck
4.I was able to clone the drive with no issues
5.I zeroed out the drive and started over
6.Used gparted to create partition table
7.created folder/directory within the external called "images"


If anyone knows why I am getting error : "Not a directory" please provide a solution.

Thanks in advance,


Question information

English Edit question
Ubuntu coreutils Edit question
No assignee Edit question
Last query:
Last reply:
delance (olivier-delance) said : #1

Have a look at software clonezilla which allow to make compressed image of partition.

dd if=/dev/sda of=/dev/sdb1/images/Win7Ubuntu.img
/dev/sdb1 is not a folder but a block device. You can't write into it. More generally, never read or write on devices under /dev. You need to save image in another folder than path /dev/sdb1
As you work under Linux, you have a folder (probably "/") which is mounted on sdb1. Choose one of sub-folder as target, like /home/bart/images/Win7Ubuntu.img

But I persist to believe you should have a look to a tool such clonezilla, which will probably be able to compress during backup itself.

Bart Opiola (bart-opiola) said : #2

Thanks Olivier for your quick response. Can you suggest a good read to understand the filing system a little better in ubuntu? All the examples and the forums i have been reading all use /dev/...

Clonezilla was also one of the options i was looking into but wanted to understand linux a little better and "dd" sounded like the right place to start.

thanks again!

Hi Bart, /dev/sda is a device file, operations on it, like reading and writing, are passed by the kernel to the device drive, a particular bit of code, for that type of device. sd* are all disk drives that act like SCSI disks, even though they may not be SCSI these days. sda will be one disk, sdb the second, etc.

Disks are often split into partitions, a purely software convention that allows different lumps to be set aside for different purposes. A table at the start of /dev/sda will state the start and end of each primary partition. The disk driver understands this convention and will make the partitions available as /dev/sda1, sda2, etc. So, say sda1 start 50,000 bytes from the start of the disk, sda. If I write to the first byte of sda1 then I'm also effectively writing to the 50,000th byte of sda. Partitions are just a way of constraining accesses to a particular area.

dd reads and writes blocks of bytes. You could copy every byte from one partition to another by saying if=/dev/sda1 of=/dev/sdb1; this assumes sdb1 is at least as large as sda1. if=/dev/sda of=/dev/sdb1 would copy all the the disk sda to a partition.

Hope that helps a little.

Bart Opiola (bart-opiola) said : #4

Why do i get this error?

root@ubuntu:~# dd if=/dev/sda of=/dev/sdb1/images bs=32M conv=notrunc
dd: opening `/dev/sdb1/images': Not a directory

Bart Opiola (bart-opiola) said : #5

Can someone post up terminal commands for dd to do the following:

1. Format an external so I can write a compressed HDD image to it.
2.create an image of my HDD
3. compress it
4. save it to my external
5. test to see if i can restore it


Bart, it sounds like you need something like Clonezilla as Oliver said.

delance (olivier-delance) said : #7

You can't make a file into /dev/sdb1. You must create file outside "/dev" folder.
"dd" is a tool which is more for geek.
Clonezilla will be more user friendly.
Else you can use an external drive and use Gparted to copy partition itself.

msniner (m8r-v7mkpa) said : #8


The dd command cannot accept an output destination of [FONT=Courier New]/dev/sd##[/FONT] if the destination is a file such as an IMG or ISO file.

In Ubuntu, all drives are located in /media. So if you know what the drive name is (it's listed in its Nautilus file explorer if you open it), for the output file or "of= ..." format you type in media/my_usb_stick or something like that.

Can you help with this problem?

Provide an answer of your own, or ask Bart Opiola for more information if necessary.

To post a message you must log in.