Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Red Hat This forum is for the discussion of Red Hat Linux.


Search this Thread
Old 03-13-2013, 07:15 PM   #1
Registered: Jun 2012
Posts: 218

Rep: Reputation: Disabled
Mounting a bootable USB stick makes the stick non-bootable

I have a process used to create bootable CentOS 6.3 installer sticks. I use a command similar to

dd if=myimage.img of=/dev/sdx bs=16k

to burn my custom image onto a USB stick, and from here I can boot my systems with one of these systems to perform the OS install.

I've hit a problem which I've never seen before that I cannot understand. After burning a USB stick, I sometimes mount it and copy additional files to it (for example for debugging purposes). So I might do this:

dd if=myimage.img of=/dev/sdx bs=16k
partx -av /dev/sdx
mount /dev/sdx1 /mnt
cp myfile.dat /mnt
umount /mnt
partx -dv /dev/sdx

After doing this, for some reason the stick is no longer bootable. The system comes up with the error "No operating system", which of course is the error you typically see when booting with a disk that had a partition flagged as bootable but there is no OS present on the disk. The OS *is* there though, so the error doesn't make sense.

What's more confusing though is all I have to do is just mount the disk--I don't even have to copy anything to it. Just the acting of burning an image to the disk and then mounting it causes it to be not bootable. Even if I mount the disk read-only, it will longer boot.

I have another bootable image created by the same process and this problem does not occur with that image. I can repeat these same steps and the stick boots fine afterwards.

So I'm stuck with this. Does anyone have any idea what's going on?
Old 03-14-2013, 07:33 PM   #2
Senior Member
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,193

Rep: Reputation: 538Reputation: 538Reputation: 538Reputation: 538Reputation: 538Reputation: 538
I have seen weird errors like yours without ever getting to an explanation. If you try the same process on a different USB stick (just another one, doesn't even have to be different) does it happen as well?

If that other one is correct, trash the problematic stick. Unless you want to research it for academic reasons. Highly unsatisfactory of course.

Old 03-14-2013, 08:32 PM   #3
Registered: Mar 2008
Posts: 11,969

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
I don't get the partx reason. (OK, don't know why you do partx)

The dd command from file to device should have been part of the original image. It shouldn't need any more partition issues unless you are trying to fill it??

Why don't you just mount or automount the usb and make changes?

Not sure I'd even use bs= either. I'm on the fence on that.

Last edited by jefro; 03-14-2013 at 08:35 PM.
Old 03-14-2013, 08:59 PM   #4
Senior Member
Registered: Aug 2009
Distribution: CentOS
Posts: 1,565

Rep: Reputation: 659Reputation: 659Reputation: 659Reputation: 659Reputation: 659Reputation: 659
You could do the simple "mount and unmount", and then compare the data on the drive with the original image (not the contents of the files, but a byte-by-byte compare of the image). I suspect it's some variant of what happens when the boot files get moved without re-installing the boot loader. Everything appears to work just fine, but the boot loader is actually using the data from the old physical locations, blocks that are now marked as "free" in the file system. Then you make some unrelated change, those free blocks get used for something else, and your system won't boot any more.

What's the file system inside that image? SWAG here: If it's ext3 or ext4, then it could be the journal that is overwriting the blocks that the boot loader is using.
Old 03-15-2013, 11:12 AM   #5
Registered: Jun 2012
Posts: 218

Original Poster
Rep: Reputation: Disabled
I resolved the problem, although I don't have a good explanation for the solution. I decided to reboot the system where I was generating my image and then created a new image. After doing this, the problem went away. I can now burn this image onto a USB stick, mount/umount the USB stick, and the USB still boots. It always used to work so I knew there was something wonky going on, but this definitely is *very* wonky.

Unfortunately I lost a day of my life before deciding to reboot the system.

'Nuff said...
Old 03-15-2013, 11:34 AM   #6
Registered: Mar 2008
Posts: 11,969

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Thanks for the update.
Old 03-15-2013, 02:44 PM   #7
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbang
Posts: 637
Blog Entries: 1

Rep: Reputation: 140Reputation: 140

Originally Posted by PeterSteele View Post
Unfortunately I lost a day of my life before deciding to reboot the system.

'Nuff said...
Then you probably wont find this clip as funny as I did!
The IT Crowd - Have you tried turning it off and on again?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
What the hell is a bootable ISO and a bootable USB-stick? duplex Linux - Software 15 11-23-2012 09:00 PM
Bootable usb stick + dd eviltoaster Linux - General 6 03-17-2010 09:08 AM
Making a USB stick bootable from a bootable cdrom cwwilson721 Slackware 2 10-23-2009 10:18 PM
How to make USB stick bootable? depam Linux - Software 3 12-31-2006 12:22 PM
bootable USB-Stick overlord73 Linux - Hardware 1 01-14-2005 03:17 AM

All times are GMT -5. The time now is 10:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration