Mount another hard disk in centos

Source: Internet
Author: User

Mount another hard disk in centos

Try to mount another hard disk in centos. One of the partitions is in LVM2 format and cannot be mounted directly. The method is recorded as follows for future use.

1. First, use vgscan to scan lvm. The result is as follows:

[Root @ localhost ~] # Vgscan
Reading all physical volumes. This may take a while...
WARNING: Duplicate VG name VolGroup00: Existing bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
WARNING: Duplicate VG name VolGroup00: Existing bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
WARNING: Duplicate VG name VolGroup00: Existing 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM (created here) takes precedence over bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh
Found volume group "VolGroup00" using metadata type lvm2
WARNING: Duplicate VG name VolGroup00: Existing bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
Found volume group "VolGroup00" using metadata type lvm2

2. view the vg uuid of lvm through vgdisplay VolGroup00

[Root @ localhost ~] # Vgdisplay VolGroup00
WARNING: Duplicate VG name VolGroup00: Existing bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
-Volume group-
VG Name VolGroup00
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 129.31 GB
PE Size 32.00 MB
Total PE 4138
Alloc PE/Size 4137/129 .28 GB
Free PE/Size 1/32.00 MB
Vg uuid bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh

It can be seen that the VolGroup00 vg uuid used by the current operating system is bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh
1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM the vg uuid is the lvm partition of another hard disk.

3. Rename the VG name of the second hard disk.

[Root @ localhost ~] # Vgrename 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM/dev/vg01
WARNING: Duplicate VG name VolGroup00: Existing bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
WARNING: Duplicate VG name VolGroup00: Existing bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh (created here) takes precedence over 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM
WARNING: Duplicate VG name VolGroup00: Existing 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM (created here) takes precedence over bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh
Volume group "VolGroup00" successfully renamed to "vg01 ″

At this time, you can see the VG information through vgdisplay.

[Root @ localhost ~] # Vgdisplay
-Volume group-
VG Name vg01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
Max lv 0
Cur LV 2
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 34.50 GB
PE Size 32.00 MB
Total PE 1104
Alloc PE/Size 1103/34 .47 GB
Free PE/Size 1/32.00 MB
Vg uuid 1WnXRG-M0t1-z1A6-rppv-lltN-oDQB-IDonTM

-Volume group-
VG Name VolGroup00
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 129.31 GB
PE Size 32.00 MB
Total PE 4138
Alloc PE/Size 4137/129 .28 GB
Free PE/Size 1/32.00 MB
Vg uuid bgKw70-NEBI-QY6s-RvqU-3a59-N8E1-ruOWwh

4. Activate VG

After the VG is renamed, It is not ACTIVE by default. We need to activate the VG in the following ways:

[Root @ localhost ~] # Lvscan
Inactive '/dev/vg01/logvol00' [31.50 GB] inherit
Inactive '/dev/vg01/logvol0' [2.97 GB] inherit
"ACTIVE"/dev/VolGroup00/logvol00' [125.41 GB] inherit
ACTIVE '/dev/VolGroup00/logvol01' [3.88 GB] inherit

Activate VG
[Root @ localhost ~] # Vgchange-ay/dev/vg01
2 logical volume (s) in volume group "vg01" now active

View status
[Root @ localhost ~] # Lvscan
"ACTIVE"/dev/vg01/logvol00' [31.50 GB] inherit
ACTIVE '/dev/vg01/logvol0' [2.97 GB] inherit
"ACTIVE"/dev/VolGroup00/logvol00' [125.41 GB] inherit
ACTIVE '/dev/VolGroup00/logvol01' [3.88 GB] inherit
[Root @ localhost ~] # Vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg01" using metadata type lvm2
Found volume group "VolGroup00" using metadata type lvm2

So far, you can mount the system!

5. Mount the lvm File System

[Root @ localhost mnt] # mount/dev/vg01/mnt/create a directory

You can access

Note: When an error is reported, mount:/dev/vg01 is not a block device, indicating that vg01 may have a multi-level directory such as "LogVol01, LogVol00". You need to enter the sub-directory of vg01 and mount it again. [Root @ localhost mnt] # mount/dev/vg01/LogVol01/mnt/create a directory

How to mount lvm partitions in linux
Fdisk-l // all hard disks are displayed below. hda is the virtual machine's own hard disk, while hdb is the mounted hard disk.

Vgscan // scan all volume groups vgdisplay // display more volume group information vgrename G8ysH1-61Mc-hVQI-YvNk-0301-KgJV-54x9CP vg01 // rename the volume group name for the mounted disk, because the volume group name is the same as that of the virtual machine itself, the lvm partition cannot be mounted and must be renamed. (To modify the volume group name of the attached disk, You need to specify which one is mounted ), vg uuid is similar to the serial number, and the volume group name is the same. You can only change the volume group name by vg uuid.

The following Volume group "VolGroup00" successfully renamed to "vg01" indicates that the name is successfully renamed.

Vgdisplay // you can see that there is already a disk named vg01lvscan // you can see that the above two disks are mounted, vgchange-ay/dev/vg01 // activate this volume group lvscan // check whether the vg01 volume group is activated mkdir/mnt/hdb // create a folder for mounting click mount/dev/vg01/logical volume name (for example, LogVol00) /mnt/hdb // Mount vg01/LogVol00

Uninstall after use

Umount/mnt/hdbvgchange-an/dev/vg01 remove activated lvm partitions

The hard disk cannot be started again when the volume group name is changed. It should be booted to the VolGroup00 volume group by default, so if you want to restart the hard disk after the volume group name is changed, you must change the volume group name to the default VolGroup00
But it cannot be modified on a virtual machine that already has a VolGroup00 volume group! Here we create a separate virtual machine with a partition format not linux lvm format to mount the hard disk. The format is ext3 (displayed as linux)

Fdisk-l // check whether the attached hard disk vgscan is identified // scan the volume group lvscan // check whether the volume group to be renamed is activated, if it is activated, the volume group name cannot be modified. If it is directly modified, the system will prompt the error vgchange-an/dev/VolGroup00 // if the previous step is activated, you need to use this command to change to the inactive status lvscan // to check whether it is changed to the inactive status vgrename vg01 VolGroup00 // to the inactive status, you can modify the volume group name

You can directly mount a linux lvm partition to an ext3-formatted virtual machine as follows:

Fdisk-l // check whether the attached hard disk vgscan // scan the volume group vgdisplay // display all the volume groups lvscan // check whether the volume group of the attached disk is in the active status vgchange -ay/dev/VolGroup00 // As shown in the previous step, run the command mkdir/mnt/hdb // to create the mount/dev/VolGroup00/LogVol00/mnt/hdb/mount folder of the mount point, after mounting, you can access/mnt/hdbumount/mnt/hdb // unmount the disk vgchange-an/dev/VolGroup00 // to remove the activation status of the mounted disk volume group.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.