LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 05-09-2011, 05:09 AM   #1
m.lukas
LQ Newbie
 
Registered: May 2011
Location: Poland
Distribution: Ubuntu 10.10
Posts: 5

Rep: Reputation: Disabled
Boot from USB Drive - force device as sda


Hi, I have system (Ubuntu 10.10) on my pendrive.
I want to use this system always from this pen - by boot on startup.

If I remove all of my hard disk from laptop and boot from pendrive - everything is ok,
but when i try boot from pen when hard disks are plugged - its not working - because linuks want pass to sda2 partition,
and this partition is already assign to wrong disk (should be in pendrive).

I have crypt(luks) and lvm on this pen.

I just want to make sure that my pendrive will be always shown as "sda" - how i can do this? I think it will probably fix my problem.

And second question:
How to disable mount other disk - mount only this pendrive.

Last edited by m.lukas; 05-09-2011 at 06:01 AM.
 
Old 05-09-2011, 05:37 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Hello,

What is your exact problem? I ask because you can not directly "force" a device to have a specified device name in linux. Your best bet is to find out what device name is being set for your flash drive, and work from there.

As far as your second question, could you explain a bit better by what you mean?

Cheers,

Josh
 
Old 05-09-2011, 05:49 AM   #3
m.lukas
LQ Newbie
 
Registered: May 2011
Location: Poland
Distribution: Ubuntu 10.10
Posts: 5

Original Poster
Rep: Reputation: Disabled
I just want to mount only pendrive and not using another disk from laptop.
Or mount it after pen.

It's quite strange that i can't force pendrive to "sda".

----
problem is when other disk are in my laptop
when linuks starts he wants to pass (luks-lvm) to decrypt partition.
He wants to decrypt sda2 - it should be one of pendrive partition, but its only on pendrive
when therse no another drives.

When other disk are mounted pendrive is not anymore sda - so i nedd to force it

Last edited by m.lukas; 05-09-2011 at 06:02 AM.
 
Old 05-09-2011, 06:49 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Use UUIDs instead of device descriptors and you should be fine. I don't know much about LUKS, but a short search on the web showed me that it can be used with UUIDs.
 
1 members found this post helpful.
Old 05-09-2011, 07:34 AM   #5
m.lukas
LQ Newbie
 
Registered: May 2011
Location: Poland
Distribution: Ubuntu 10.10
Posts: 5

Original Poster
Rep: Reputation: Disabled
yes i know that, but i just don't want to mess with crypttab & fstab because after that update-initramfs make somethink wrong and whole pendrive just go down.
 
Old 05-09-2011, 09:05 AM   #6
frenezulo
LQ Newbie
 
Registered: Aug 2010
Posts: 6

Rep: Reputation: 1
I think TobiSG is right about using UUIDs. Just forcing a device to be sda would have to be done with some sort of unique descriptor anyway. That's why we have UUIDs in the first place.

I have done something like what you are trying to do using Debian/LILO on an SD card. If you like I could post some example configuration files later. I have a "live" bootable Linux on an SD card now that is independant of what computer i place it into.
 
Old 05-09-2011, 09:37 AM   #7
Latios
Member
 
Registered: Dec 2010
Distribution: Arch
Posts: 115

Rep: Reputation: 21
My system is set up with UUIDs for the exact reason (i sometimes swap out the hard drive with computers that have more than 1 drive)

/boot/grub/menu.lst

Code:
# Config file for GRUB - The GNU GRand Unified Bootloader
# /boot/grub/menu.lst

# DEVICE NAME CONVERSIONS 
#
#  Linux           Grub
# -------------------------
#  /dev/fd0        (fd0)
#  /dev/sda        (hd0)
#  /dev/sdb2       (hd1,1)
#  /dev/sda3       (hd0,2)
#

#  FRAMEBUFFER RESOLUTION SETTINGS
#     +-------------------------------------------------+
#          | 640x480    800x600    1024x768   1280x1024
#      ----+--------------------------------------------
#      256 | 0x301=769  0x303=771  0x305=773   0x307=775
#      32K | 0x310=784  0x313=787  0x316=790   0x319=793
#      64K | 0x311=785  0x314=788  0x317=791   0x31A=794
#      16M | 0x312=786  0x315=789  0x318=792   0x31B=795
#     +-------------------------------------------------+
#  for more details and different resolutions see
#  http://wiki.archlinux.org/index.php/GRUB#Framebuffer_Resolution 

# general configuration:
timeout   5
default   0
color light-blue/black light-cyan/blue

# boot sections follow
# each is implicitly numbered from 0 in the order of appearance below
#
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
#
#-*

# (0) Arch Linux
title  Arch Linux
root   (hd0,0)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/8d26b115-cd43-4024-8345-d5bf79e4f43b ro
initrd /boot/kernel26.img

# (1) Arch Linux
title  Arch Linux Fallback
root   (hd0,0)
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/8d26b115-cd43-4024-8345-d5bf79e4f43b ro
initrd /boot/kernel26-fallback.img

# (2) Windows
#title Windows
#rootnoverify (hd0,0)
#makeactive
#chainloader +1
/etc/fstab
Code:
# 
# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
devpts                 /dev/pts      devpts    defaults            0      0
shm                    /dev/shm      tmpfs     nodev,nosuid        0      0

#/dev/cdrom             /media/cd   auto    ro,user,noauto,unhide   0      0
#/dev/dvd               /media/dvd  auto    ro,user,noauto,unhide   0      0
#/dev/fd0               /media/fl   auto    user,noauto             0      0

UUID=54859e62-fd44-4578-b879-e0bc4fdeb684 swap swap defaults 0 0
UUID=8d26b115-cd43-4024-8345-d5bf79e4f43b / ext3 defaults 0 1
UUID=b6dc5569-27d1-4151-8e9f-9c77a2840c3b /home ext3 defaults 0 1
Get the UUIDs with 'ls -al /dev/disk/by-uuid/'
 
Old 05-09-2011, 09:01 PM   #8
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
I'm a bit late into this thread, but I third about using UUIDs. That's how I do it on my server.
 
Old 05-12-2011, 04:55 AM   #9
m.lukas
LQ Newbie
 
Registered: May 2011
Location: Poland
Distribution: Ubuntu 10.10
Posts: 5

Original Poster
Rep: Reputation: Disabled
My /etc/crypttab look like this:
Code:
# <target name>	<source device>		<key file>	<options>
pvcrypt		/dev/sda2	none	luks,retry=1,lvm=vg
#pvcrypt 	/dev/disk/bu-uuid/1591f0c6-cebe-4c2c-b5d3-c32a3c7a790c	none	luks,retry=1,lvm=vg
and my /etc/fstab is here:
Code:
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/mapper/vg-root /               ext3    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
/dev/sda1	/boot           ext2    defaults        0       2
#UUID=903d629a-e2b4-4b4a-8609-f0d11a2401ca /boot           ext2    defaults        0       2
/dev/mapper/vg-home /home           ext3    defaults        0       2
/dev/mapper/vg-swap none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
when im trying to change lines to UUID and comment previous and i'm initialize:
Code:
# sudo update-initramfs -k all -c
everything its going wrong - i just can to type password on start anymore.


Sometimes - when im try to edit pendrive-system from another linuks (vmware ubuntu 10.10) by typing:

Code:
cd /mnt
sudo mkdir root
sudo mount -t ext3 /dev/mapper/vg-root /mnt/root
sudo mount -t ext2 /dev/sdb1 /mnt/root/boot
sudo mount -t ext3 /dev/mapper/vg-home /mnt/root/home

sudo chroot /mnt/root
mount -t proc proc /proc
mount -t sysfs sys /sys
mount -t devpts devpts /dev/pts

gedit /etc/crypttab  #editing crypttab
gedit /etc/fstab  #editing fstab

sudo update-initramfs -k all -c

after "update-initramfs -k all -c" i got info - somthing like this:
Code:
cryptsetup: WARNING: invalid line in /etc/crypttab -

what can i do to use UUID ?

my etc/default/grub is here:
Code:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"


for crypt and lvm im using this tutorial - and everything is fine, when i just don't have more disk-drives, only this pendrive.

https://help.ubuntu.com/community/En...systemLVMHowto

so what i need to do is only change to UUID, or make my pendrive as "sda"

---------

and another strange error when im trying update-initramfs under pendrive system - when im usung it (maybe i cannot update this when im using this system) :


cpio: not implemented or invalid option --
E: mkinitramfs failure find 141 cpio 1 gzip 0


Last edited by m.lukas; 05-12-2011 at 08:54 AM.
 
Old 05-12-2011, 05:03 AM   #10
m.lukas
LQ Newbie
 
Registered: May 2011
Location: Poland
Distribution: Ubuntu 10.10
Posts: 5

Original Poster
Rep: Reputation: Disabled
maybe i should run some command do update some another boot scripts - I really have no idea what to do
 
Old 05-13-2011, 03:55 PM   #11
Latios
Member
 
Registered: Dec 2010
Distribution: Arch
Posts: 115

Rep: Reputation: 21
/etc/default/grub looks empty. Post /boot/grub/grub.cfg instead



Basically you have to :

Add # to the /dev/sdX lines and remove # from the UUID or /dev/disk/by-uuid lines, in fstab and crypttab

Change root=/dev/sdX to root=/dev/disk/by-uuid/X in the kernel line in grub



I see there is some /dev/mapper stuff in fstab, so maybe you use LVM or something like that. I am not familiar with LVM and maybe doing what i said to a LVM system can render it unbootable

You can try. If you damaged your system and it won't boot, start the computer ith a live USB or CD and change everything back in all the files
 
  


Reply



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
Installing RIP LinuX on a USB drive - device name /dev/sdc becomes /dev/sda Mleahy Linux - Software 1 07-30-2008 08:57 PM
Buffer I/O error on device sda. Lost hard drive? shanekelly64 Linux - Newbie 1 11-12-2007 11:32 AM
How to force kernel to use a USB 2.0-compatible device (ehci_hcd) as a USB 1.1 device eze Linux - Hardware 0 05-16-2006 05:24 AM
USB flash device (sda missing) TroelsSmit Linux - Newbie 13 02-06-2006 09:45 PM
Maxtor Usb harddrive. Buffer I/O error on device sda. sfumato Linux - Hardware 3 12-26-2005 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 02:13 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration