LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
Search this Thread
Old 03-13-2013, 06:15 PM   #1
PeterSteele
Member
 
Registered: Jun 2012
Posts: 205

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, 06:33 PM   #2
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 4,065

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491
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.

jlinkels
 
Old 03-14-2013, 07:32 PM   #3
jefro
Guru
 
Registered: Mar 2008
Posts: 11,327

Rep: Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386
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 07:35 PM.
 
Old 03-14-2013, 07:59 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,415

Rep: Reputation: 594Reputation: 594Reputation: 594Reputation: 594Reputation: 594Reputation: 594
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, 10:12 AM   #5
PeterSteele
Member
 
Registered: Jun 2012
Posts: 205

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, 10:34 AM   #6
jefro
Guru
 
Registered: Mar 2008
Posts: 11,327

Rep: Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386
Thanks for the update.
 
Old 03-15-2013, 01:44 PM   #7
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbang
Posts: 605
Blog Entries: 1

Rep: Reputation: 139Reputation: 139
Talking

Quote:
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?
 
  


Reply


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 08:00 PM
Bootable usb stick + dd eviltoaster Linux - General 6 03-17-2010 08:08 AM
Making a USB stick bootable from a bootable cdrom cwwilson721 Slackware 2 10-23-2009 09:18 PM
How to make USB stick bootable? depam Linux - Software 3 12-31-2006 11:22 AM
bootable USB-Stick overlord73 Linux - Hardware 1 01-14-2005 02:17 AM


All times are GMT -5. The time now is 01:04 PM.

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