Linux를 제거하고 다시 설치하지 않고(또는 데이터 손실) 루트 파티션의 크기를 조정할 수 있습니까?

Linux를 제거하고 다시 설치하지 않고(또는 데이터 손실) 루트 파티션의 크기를 조정할 수 있습니까?

저는 Debian과 Windows 7이 모두 설치된 컴퓨터를 사용하기 시작했습니다. 그런데 일부 프로그램을 설치한 후 공간이 부족하다는 메시지가 나오기 시작했습니다. 나는 시스템에 총 1TB 이상의 하드 드라이브 공간이 있다는 것을 알고 몇 가지 조사를 수행했습니다. 루트 파티션은 5GB에 불과한 것으로 보입니다.

Linux를 다시 설치하지 않고 특정 파티션에 더 많은 디스크 공간을 할당할 수 있는 방법이 있습니까?

아래에서 내가 실행한 몇 가지 명령의 결과를 확인할 수 있습니다.

fdisk -l

Disk /dev/sda: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 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: 0x4a47e2fd

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2              13       53507   429687500    7  HPFS/NTFS
Partition 2 does not end on cylinder boundary.
/dev/sda3           53507       77826   195340289    5  Extended
Partition 3 does not end on cylinder boundary.
/dev/sda5           53507       53537      243712   83  Linux
/dev/sda6           53538       77826   195095552   8e  Linux LVM

Disk /dev/sdb: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 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: 0x4a47e2fe

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               2       62261   500097657+   f  W95 Ext'd (LBA)
/dev/sdb5               2       62261   500097656+   7  HPFS/NTFS

Disk /dev/dm-0: 4999 MB, 4999610368 bytes
255 heads, 63 sectors/track, 607 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: 0x00000000

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 1996 MB, 1996488704 bytes
255 heads, 63 sectors/track, 242 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: 0x00000000

Disk /dev/dm-1 doesn't contain a valid partition table

Disk /dev/dm-2: 20.0 GB, 19998441472 bytes
255 heads, 63 sectors/track, 2431 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: 0x00000000

Disk /dev/dm-2 doesn't contain a valid partition table

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/HU-root   4.6G  4.4G   32M 100% /
tmpfs                 2.0G     0  2.0G   0% /lib/init/rw
udev                  2.0G  220K  2.0G   1% /dev
tmpfs                 2.0G  356K  2.0G   1% /dev/shm
/dev/sda5             231M   22M  198M  10% /boot
/dev/mapper/HU-home    19G  751M   17G   5% /home

편집(댓글을 기반으로 한 추가 정보):

# mount
/dev/mapper/HU-root on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/sda5 on /boot type ext3 (rw)
/dev/mapper/HU-home on /home type ext3 (rw)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)

# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda6
  VG Name               HU
  PV Size               186.06 GiB / not usable 3.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              47630
  Free PE               41194
  Allocated PE          6436
  PV UUID               wmEFAc-eSb6-r3qo-jIjy-vuKH-v9JK-eQfJFZ

참고로, 이러한 주제(파일 시스템, 다양한 운영 체제가 파일 시스템을 이해하는 방법 등)를 깊이 있게 설명하는 좋은 책을 제안해 주시면 감사하겠습니다.

답변1


경고하다: 알려진 복구 가능한 백업 없이 파일 시스템에서 작업을 수행하는 것은 현명하지 않습니다.


깨끗하다는 확신이 없으면 /다음 단계를 수행하지 마세요.확실하지 않은 경우 루트로 다음 명령을 실행하십시오.

# touch /forcefsck

그리고 다시 시작하세요. fsck안전을 위해 모든 파티션에 대한 작업이 완료됩니다.


하지만 LVM을 루트 장치 및 ext3파일 시스템으로 사용하고 있으므로 온라인으로 확장할 수 있습니다. resize2fs시작하기 전에 설치 되어 있는지 확인하세요 . 그렇지 않은 경우 일반적으로 e2fsprogs. (공간이 부족해서 설치할 수 없다면 정리를 좀 해보세요 /var/log.)

먼저 다음을 사용하여(루트로) 기본 볼륨을 확장합니다.

# lvextend -L+2G /dev/mapper/HU-root

(필요에 따라 섹션을 조정하십시오 2G. 이것이 추가하려는 공간의 양입니다.)

그런 다음 파일 시스템의 크기를 조정해야 합니다. 이 작업은 다음을 통해 온라인으로 수행할 수 있습니다 resize2fs.

# resize2fs /dev/mapper/HU-root

몇 초/몇 분이 걸릴 수 있습니다. 방해하지 마. /forcefsck원하는 경우 마지막으로 한 번 재부팅 하거나 한 번 더 재부팅합니다. 꼭 필요한 것은 아니지만 항상 그렇게 합니다.

답변2

PV에 / 파티션에 할당할 여유 공간이 있습니다. 다음 명령을 사용하여 /dev/mapper/HU-root의 공간을 늘릴 수 있습니다.

lvextend -L +10G /dev/mapper/HU-root
e2resize /dev/mapper/HU-root

위 명령은 볼륨 그룹의 10G를 HU 루트 논리 볼륨에 추가합니다. e2resize 명령은 남은 여유 공간을 사용하도록 ext3 파일 시스템을 "확대"합니다.

답변3

출력 에서 lvdisplay크기 조정/확장하려는 루트 파티션의 경로를 선택합니다.

관련 정보