Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Mount another ubuntu root file system on ubuntu

Posted on 2011-05-08
39
Medium Priority
?
1,027 Views
Last Modified: 2012-06-21
Hi there,

How can I mount another file system on Ubuntu? Here are my file system

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0x000a780b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          32      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              32       60802   488135681    5  Extended
/dev/sda5              32       60802   488135680   8e  Linux LVM

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0x000a780b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          32      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sdb2              32       60802   488135681    5  Extended
/dev/sdb5              32       60802   488135680   8e  Linux LVM

They are almost two identical disk both installed Ubuntu Server.
Now the system is running on sda, I want to use sdb as a data partition but want to keep its file system (no formatting). However, I can mount sdb1, but I find that I cannot just mount /dev/sdb5 /media/data or mount -t ext4 /dev/sdb5 /media/data. Would you please tell me how to achieve it?

Regards
0
Comment
Question by:Promodel
  • 19
  • 19
39 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 35717399
Just create entry in /etc/fstab file and issue command mount -a

You can mount any partition that you want.  I don't understand the problem you encountered.

Edit file /etc/fstab

vi /etc/fstab

Insert the following
/dev/sdb1  /mount/point ext4    defaults 0 0
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35717400
You have LVM on both disks.
you need to mount the logic volume for another disk.

Please post the output of the following commands here.
# pvdisplay
# vgdisplay
# lvdisplay
0
 

Author Comment

by:Promodel
ID: 35717414
pvdisplay:
Found duplicate PV S4A3gcVFjyN2R07YeT0kD4UEc20NZIY2: using /dev/sdb5 not /dev/sda5
  --- Physical volume ---
  PV Name               /dev/sdb5
  VG Name               tbl-new-server
  PV Size               465.52 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              119173
  Free PE               12
  Allocated PE          119161
  PV UUID               S4A3gc-VFjy-N2R0-7YeT-0kD4-UEc2-0NZIY2

vgdisplay:
Found duplicate PV S4A3gcVFjyN2R07YeT0kD4UEc20NZIY2: using /dev/sdb5 not /dev/sda5
  --- Volume group ---
  VG Name               tbl-new-server
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               465.52 GiB
  PE Size               4.00 MiB
  Total PE              119173
  Alloc PE / Size       119161 / 465.47 GiB
  Free  PE / Size       12 / 48.00 MiB
  VG UUID               MUUEfI-EI3K-kIJ4-ssww-5SEA-x2Nl-djvAuG

lvdisplay:
Found duplicate PV S4A3gcVFjyN2R07YeT0kD4UEc20NZIY2: using /dev/sdb5 not /dev/sda5
  --- Logical volume ---
  LV Name                /dev/tbl-new-server/root
  VG Name                tbl-new-server
  LV UUID                KEaXpj-M8N7-xcL7-IcJC-NUjN-V0Ug-6zZLsL
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                459.72 GiB
  Current LE             117688
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:0

  --- Logical volume ---
  LV Name                /dev/tbl-new-server/swap_1
  VG Name                tbl-new-server
  LV UUID                rUkg8t-mb6j-MGq9-1Qwn-qdb6-ZW00-L5w0Q1
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                5.75 GiB
  Current LE             1473
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:1

0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 38

Expert Comment

by:wesly_chen
ID: 35717431
It looks that you do disk clone for the disk so they have the same UUID.
do
# sudo pvchange -u /dev/sdb5
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35717435
once you change the UUID, then do
sudo pvscan
to see if you can see both PV for /dev/sda5 and /dev/sdb5. If not, then reboot and check.
0
 

Author Comment

by:Promodel
ID: 35717441
Yes, exactly.

sudo pvchange -u /dev/sdb5

Found duplicate PV S4A3gcVFjyN2R07YeT0kD4UEc20NZIY2: using /dev/sda5 not /dev/sdb5
  Volume group containing /dev/sda5 has active logical volumes
  0 physical volumes changed / 1 physical volume not changed
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35717447
Do you have Ubuntu boot CD/DVD so you can boot ubuntu from DVD as liveCD?
Then do
sudo pvchange -u /dev/sdb5

The LVM is confused by duplicate PV UUID.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35717464

here is the tutorial to boot from liveCD and pvscan
http://linuxwave.blogspot.com/2007/11/mounting-lvm-disk-using-ubuntu-livecd.html
0
 

Author Comment

by:Promodel
ID: 35717509
Even I run it in liveCD, it produce the same result, duplicate PV using sdb5 not sda5.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35717515
OK. disconnect the first disk and boot from liveCD and run pvchange -u for the second disk
0
 

Author Comment

by:Promodel
ID: 35717540
pvchange -u /dev/sda5
  Volume group containing /dev/sda5 has active logical volumes
  0 physical volumes changed / 1 physical volume not changed

What does pvchange do? I think we have to make system recognize the partitions on other disk and allocation UUID to it.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35717567
ok, deactivate the logic volume first.
sudo  lvchange -an
or
sudo lvchange -an root
sudo lvchange -an swap_1
(do lvscan to check the LV name)

Then deactivate volume group
sudo vgchange -an

sudo pvchange -u /dev/sda5

sudo vgrename /dev/tbl-new-server /dev/tbl-new-server-old

0
 

Author Comment

by:Promodel
ID: 35717707
After we change its name, we cannot boot from that disk except we rename it when we need to boot it. So we cannot access such disk without changing its name? if so, we might not use it as a data disk.

Thanks wesly.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35717721
check the /etc/lvm/lvm.conf on that disk and change it for the new vg name.
Also remove /etc/lvm/cache/.cache on that disk if there is any.
0
 

Author Comment

by:Promodel
ID: 35725242
I did not find any lines in lvm.conf to configure vg name. Also, nothing returned by using grep 'tbl'.

only names can be found in .cache
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35725255
With boot from LiveCD, what's the output for
pvscan
vgscan
lvscan
0
 

Author Comment

by:Promodel
ID: 35725487
pvscan
/dev/sda5 VG tbl-new-server-old lvm2 ...... in no VG: 0[0]

vgscan
Found volume group "tbl-new-server-old" using metadata type lvm2

lvscan
inactive '/dev/tbl-new-server-old/root'
inactive '/dev/tbl-new-server-old/swap_1'
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35725606
The output look ok.
To activate the vg and lv
# sudo vgchange -ay
# sudo lvchange -ay

and post the output of lvm.conf for "filer = [ "
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35725616
By the way, has the PV UUID  been changed on the disk drive?

Can you boot from this disk with vg "tbl-new-server-old"?
0
 

Author Comment

by:Promodel
ID: 35725627
Now I try booting system from the disk without changing name.  
When pvscan, only sdb5 is seen and the system is running on sdb

pvscan:
PV /dev/sdb5   VG tbl-new-server   lvm2 [465.52 GiB / 48.00 MiB free]
  Total: 1 [465.52 GiB] / in use: 1 [465.52 GiB] / in no VG: 0 [0   ]

sudo lvscan
  ACTIVE            '/dev/tbl-new-server/root' [459.72 GiB] inherit
  ACTIVE            '/dev/tbl-new-server/swap_1' [5.75 GiB] inherit
  ACTIVE            '/dev/tbl-new-server-old/root' [459.72 GiB] inherit
  ACTIVE            '/dev/tbl-new-server-old/swap_1' [5.75 GiB] inherit
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35725637
what's the output for
sudo pvdisplay
sudo vgdisplay
0
 

Author Comment

by:Promodel
ID: 35725643
I cannot boot from the disk changed to tbl-new-server-old, but plugin both. how can I check whether sda has been allocated uuid?
0
 

Author Comment

by:Promodel
ID: 35725653
sudo pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdb5
  VG Name               tbl-new-server
  PV Size               465.52 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              119173
  Free PE               12
  Allocated PE          119161
  PV UUID               S4A3gc-VFjy-N2R0-7YeT-0kD4-UEc2-0NZIY2

sudo vgdisplay
  --- Volume group ---
  VG Name               tbl-new-server
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               465.52 GiB
  PE Size               4.00 MiB
  Total PE              119173
  Alloc PE / Size       119161 / 465.47 GiB
  Free  PE / Size       12 / 48.00 MiB
  VG UUID               MUUEfI-EI3K-kIJ4-ssww-5SEA-x2Nl-djvAuG

I think only sdb is allocated uuid

0
 

Author Comment

by:Promodel
ID: 35725683
Sorry, here is output from lvdisplay

sudo lvdisplay
  --- Logical volume ---
  LV Name                /dev/tbl-new-server/root
  VG Name                tbl-new-server
  LV UUID                KEaXpj-M8N7-xcL7-IcJC-NUjN-V0Ug-6zZLsL
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                459.72 GiB
  Current LE             117688
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:0

  --- Logical volume ---
  LV Name                /dev/tbl-new-server/swap_1
  VG Name                tbl-new-server
  LV UUID                rUkg8t-mb6j-MGq9-1Qwn-qdb6-ZW00-L5w0Q1
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                5.75 GiB
  Current LE             1473
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:1

  --- Logical volume ---
  LV Name                /dev/tbl-new-server-old/root
  VG Name                tbl-new-server-old
  LV UUID                KEaXpj-M8N7-xcL7-IcJC-NUjN-V0Ug-6zZLsL
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                459.72 GiB
  Current LE             117688
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:0

  --- Logical volume ---
  LV Name                /dev/tbl-new-server-old/swap_1
  VG Name                tbl-new-server-old
  LV UUID                rUkg8t-mb6j-MGq9-1Qwn-qdb6-ZW00-L5w0Q1
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                5.75 GiB
  Current LE             1473
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:1
0
 

Author Comment

by:Promodel
ID: 35725727
lvscan reads the volume is active
sudo lvscan
  ACTIVE            '/dev/tbl-new-server/root' [459.72 GiB] inherit
  ACTIVE            '/dev/tbl-new-server/swap_1' [5.75 GiB] inherit
  ACTIVE            '/dev/tbl-new-server-old/root' [459.72 GiB] inherit
  ACTIVE            '/dev/tbl-new-server-old/swap_1' [5.75 GiB] inherit

but when I try to mount it
mount: special device /dev/tbl-new-server-old/root does not exist
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35725739
So /dev/sda is connected?
sudo pvchange -u /dev/sda5
0
 

Author Comment

by:Promodel
ID: 35725751
sudo pvchange -u /dev/sda5
  Volume group containing /dev/sda5 has active logical volumes
  0 physical volumes changed / 1 physical volume not changed

then mount
mount: special device /dev/tbl-new-server-old/root does not exist
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35725758
>  Volume group containing /dev/sda5 has active logical volumes
sudo lvchange -an /dev/tbl-new-server-old/root
sudo lvchange -an /dev/tbl-new-server-old/swap_1
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35725760
then do
sudo pvchange -u /dev/sda5
0
 

Author Comment

by:Promodel
ID: 35725779
sudo pvchange -u /dev/sda5
  Volume group containing /dev/sda5 has active logical volumes
  0 physical volumes changed / 1 physical volume not changed

still not working :(
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35725806
In my previous post:
#a35717567

What happen for pvchange in LiveCD?

Also and post the output of lvm.conf for "filer = [ "
0
 

Author Comment

by:Promodel
ID: 35725826
cat /etc/lvm/lvm.conf | grep "filter"
    # A filter that tells LVM2 to only use a restricted set of devices.
    # The filter consists of an array of regular expressions.  These
    # Don't have more than one filter line active at once: only one gets used.
    filter = [ "a/.*/" ]
    # filter = [ "r|/dev/cdrom|" ]
    # filter = [ "a/loop/", "r/.*/" ]
    # filter =[ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ]
    # filter = [ "a|^/dev/hda8$|", "r/.*/" ]
    # The results of the filtering are cached on disk to avoid

I did not pvchange in liveCD, try it later if lvm.conf does not help
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35725864
> filter = [ "a/.*/" ]
commemt out the line above and add
filter = [ "a|/dev/sda5|","a|/dev/sdb5|","r/.*/" ]

Then
sudo pvscan
to see if the sda5 show up.
0
 

Author Comment

by:Promodel
ID: 35725950
No, sda5 does not show up.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35725989
fdisk -l /dev/sda
0
 

Author Comment

by:Promodel
ID: 35726000
sudo fdisk -l /dev/sda

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0x000a780b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          32      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              32       60802   488135681    5  Extended
/dev/sda5              32       60802   488135680   8e  Linux LVM
0
 

Author Comment

by:Promodel
ID: 35726043
OK, it is pain to deal with lvm. I would rather use another disk as data disk instead.
0
 
LVL 38

Accepted Solution

by:
wesly_chen earned 250 total points
ID: 35726156
Sorry, something messed up there.
redo the clone disk

and boot from the LiveCD with second drive.
# sudo pvscan
If you see /dev/sda5, then
sudo pvchange -u /dev/sda5

I dont know why the -u isn't in the man pages but it works.

You may also need to change the VG UUID and names with
sudo vgchange -u tbl-new-server

then
vgrename tbl-new-server  tbl-old-server

You might need to deactivate lv
by
lvchange -an
if failed to do pvchange
0
 

Author Closing Comment

by:Promodel
ID: 35726218
Thanks for your work. We prefer using another disk. If we need to solve such problem in the future, it will be posted here again.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question