
CentOS 5 가상 머신이 있고 디스크 크기에 20GB를 더 추가했습니다. 사용 가능한 공간을 어떻게 초기화하고 확장하나요?
GParted도 로드하려고 시도했지만 드라이브가 잠겨 있습니다. 어떻게 잠금 해제하나요?
답변1
파일 시스템이 LVM에 있고 GParted가 이를 지원하지 않기 때문에 GParted를 사용할 수 없습니다.
먼저 VM을 백업하세요. 그런 다음 명령줄에서 "루트"로 다음을 수행합니다.
이미 재부팅한 것 같지만 만약을 대비해 커널이 더 큰 디스크를 인식하는지 확인하세요.
echo 1 > /sys/class/scsi_disk/0:0:0:0/device/rescan
fdisk를 사용하여 두 번째 파티션 크기 조정
fdisk /dev/sda p # print current d # delete - 2 n # create - p # primary partition 2 # partition number - default first/last cylinders t # change partition id - 2 - 8e (hex code) p # print the current again to verify it's expanded w # write changes
가상 머신 재부팅
shutdown -r now
백업이 완료되면 LVM 물리 볼륨의 크기를 조정하세요.
pvresize /dev/sda2
이제 LVM 논리 볼륨(메모:스크린샷을 기반으로 논리 볼륨 이름이 무엇인지 해독할 수 없으므로
LogVol00
. 를 실행하여 이를 확인할 수 있습니다lvdisplay
.)lvresize -l +100%FREE /dev/VolGroup00/LogVol00
마지막으로 파일 시스템의 크기를 조정해 보겠습니다.
resize2fs -p /dev/VolGroup00/LogVol00
파일 시스템이 더 큰지 확인
df -h
완료
답변2
아래 단계는 Centos 6 EXT4 VPS를 실행하는 VMWare EXSi 5.5에서 내 파티션을 12G에서 26GB로 확장했습니다.
1) 기본적으로 /dev/sda인 장치 이름을 식별하고 다음 명령을 실행하여 새 크기를 확인합니다.
# fdisk -l
2) /dev/sda 장치의 파티션 목록을 가져옵니다.
# ls -al /dev/sda*
brw-rw---- 1 root disk 8, 0 Dec 29 15:32 /dev/sda
brw-rw---- 1 root disk 8, 1 Dec 29 15:32 /dev/sda1
brw-rw---- 1 root disk 8, 2 Dec 29 15:32 /dev/sda2
3) 새로운 기본 파티션 생성
# fdisk /dev/sda
Then type:
n (enter) [create new partition]
p (enter) [primary partition]
3 (enter) [next available number from listed /dev/sda partitions in 2)
(enter) [start cylinder]
(enter to use all available physical space) or specify size in +cylinders, +size{K,M,G}
t (enter) [change partition type]
3 (enter) [selecting /dev/sda3 partition]
8e (enter) [this sets partition type to Linux LVM or type L then enter to see list of types]
w (enter)
The partition table has been altered!
4) Centos 6.X를 재부팅한 후 루트 권한으로 다시 로그인하세요.
# reboot
5) 새 파티션이 준비되었는지 확인하고 '8e'를 입력합니다.
# fdisk -l
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2089 16264192 8e Linux LVM
/dev/sda3 2089 3916 14678054 8e Linux LVM
6) 물리 볼륨 생성:
# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
7) 볼륨 그룹 이름을 찾으십시오.
# vgdisplay
--- Volume group ---
VG Name vg_app1
...
8) 물리적 볼륨을 확장합니다.
# vgextend vg_app1 /dev/sda3
Volume group "vg_app1" successfully extended
9) 기존 볼륨 그룹을 새 물리 볼륨으로 확장합니다(+100% 무료는 원하는 크기로 변경 가능). 루트 파티션을 확장하므로 vg_app1 볼륨 그룹의 lv_root를 가리킵니다.
# lvextend -l +100%FREE /dev/vg_app1/lv_root
Size of logical volume vg_app1/lv_root changed from 11.63 GiB (2978 extents) to 25.63 GiB (6561 extents).
Logical volume lv_root successfully resized
10) 논리 루트 볼륨 크기 조정:
# resize2fs /dev/vg_app1/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_app1/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/vg_app1/lv_root to 6718464 (4k) blocks.
The filesystem on /dev/vg_app1/lv_root is now 6718464 blocks long.
참고: Red Hat 가상 머신인 경우 resize2fs 대신 ext2online을 사용하십시오.
11) 사용 가능한 공간을 확인하십시오.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_app1-lv_root
26G 10G 14G 42% /
tmpfs 9.8G 0 9.8G 0% /dev/shm
/dev/sda1 477M 88M 364M 20% /boot
답변3
쉬운. VM에 루트로 이동합니다. "fdisk -l"을 입력하세요. 새 디스크 크기가 이미 표시되어 있다면 좋습니다.
그렇지 않은 경우 시도해 보십시오 partprobe
. 그래도 새 디스크 크기가 표시되지 않으면 재부팅하십시오.
지금fdisk /dev/sda
- 두 번째 파티션의 시작 실린더를 적어 두십시오.
- 두 번째 파티션을 "삭제"
- 동일한 시작 실린더, 끝을 위한 마지막 실린더인 두 번째 파티션을 다시 만듭니다.
- 다시 생성된 파티션 유형을 8e(LVM)로 설정합니다.
- 변경 사항을 작성하고 fdisk를 종료합니다.
partprobe
pvresize /dev/sda2
이제 VG VolGroup00에는 20GB 더 많은 공간이 있습니다. 당신이 좋아하는 것은 무엇이든 하세요. 실제 시스템에서와 마찬가지로(예를 들어 LV 크기를 조정한 다음 FS 크기를 조정)
답변4
여기서는 데이터 손실 없이 디스크를 5GB에서 7GB로 확장하기 위해 샘플 파티션을 사용하고 있습니다. 사용 가능한 여유 공간에 따라 변경할 수 있습니다.
디스크를 늘리기 전에 Linux VM에서 다음 세부 정보를 가져왔습니다.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.8G 2.1G 4.5G 32% /
/dev/sda1 99M 12M 83M 13% /boot
none 252M 0 252M 0% /dev/shm
/dev/sdb1 5.0G 39M 4.7G 1% /mnt/test
# fdisk -s /dev/sdb
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 652 5237158+ 83 Linux
지금 VM을 종료하세요.
/dev/sdb
이제 VMware 명령 프롬프트에서 기존 가상 디스크( )를 늘리겠습니다 . 참고: 이 작업은 VM의 전원이 꺼진 경우에만 수행해야 합니다.
가상 디스크 위치로 이동합니다.
# vmware-vdiskmanager -x 7Gb RedHatEnterprise_Linux_4-0.vmdk
이제 가상 디스크가 7GB로 늘어납니다.
이제 VM의 전원을 켜야 합니다. PuTTY 또는 콘솔을 사용하여 루트 사용자로 VM에 로그인합니다.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.8G 2.1G 4.5G 32% /
/dev/sda1 99M 12M 83M 13% /boot
none 252M 0 252M 0% /dev/shm
/dev/sdb1 5.0G 39M 4.7G 1% /mnt/test
여전히 이전 크기를 보여줍니다. 늘릴 파티션을 마운트 해제합니다.
# umount /dev/sdb1
디스크에서 파일 시스템 복구 실행
# fsck -n /dev/sdb1
이제 디스크에서 저널을 제거하여 ext2 파일 시스템으로 만들려고 합니다.
# tune2fs -O ^has_journal /dev/sdb1
이제 /dev/sdb
늘어난 공간을 에 할당하기 위해 파티셔닝을 시작합니다 /dev/sdb1
. 참고: 당황하지 마십시오. 여기서 데이터는 손실되지 않습니다.
기존 공간을 제거 /dev/sdb1
하고 사용 가능한 여유 공간과 함께 다시 만들고 있습니다.
# fdisk /dev/sdb
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/sdb: 7516 MB, 7516192768 bytes
255 heads, 63 sectors/track, 913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 652 5237158+ 83 Linux
Command (m for help): d
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-913, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-913, default 913):
Using default value 913
Command (m for help): p
Disk /dev/sdb: 7516 MB, 7516192768 bytes
255 heads, 63 sectors/track, 913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 913 7333641 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
이제 Linux 시스템을 다시 시작하여 파티션을 적용합니다( 를 사용할 수도 있으며 partprobe
시스템을 다시 시작하는 것이 엄격히 권장됩니다).
# shutdown now -r
이제 확장 파일 시스템을 다시 한 번 확인하십시오. 이 단계를 건너뛰면 resize2fs
명령에서 실행을 권장합니다.
# e2fsck -f /dev/sdb1
e2fsck 1.35 (28-Feb-2004)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdb1: 13/655360 files (7.7% non-contiguous), 22121/1309289 blocks
이제 파일 시스템의 크기를 조정하십시오.
# resize2fs /dev/sdb1
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/sdb1 to 1833410 (4k) blocks.
The filesystem on /dev/sdb1 is now 1833410 blocks long.
이제 파일 시스템을 확인하십시오.
# fsck -n /dev/sdb1
fsck 1.35 (28-Feb-2004)
e2fsck 1.35 (28-Feb-2004)
/dev/sdb1: clean, 13/917504 files, 30538/1833410 blocks
이제 ext3 형식으로 파티션을 다시 만듭니다.
# tune2fs -j /dev/sdb1
tune2fs 1.35 (28-Feb-2004)
Creating journal inode: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
ext3 파일 시스템을 효과적으로 사용하려면 Linux 시스템을 한 번 다시 시작하십시오.
# shutdown -r now
다시 한 번 루트 권한을 사용하여 Linux 상자에 로그인합니다. 이제 파티션이 7GB로 증가한 것을 확인할 수 있습니다.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.8G 2.1G 4.5G 32% /
/dev/sda1 99M 12M 83M 13% /boot
none 252M 0 252M 0% /dev/shm
/dev/sdb1 6.9G 39M 6.7G 1% /mnt/test