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


警告する:既知の回復可能なバックアップなしでファイルシステムで作業を実行するのは賢明ではありません。


きれいだと確信していない場合は、次の/手順を実行しないでください。不明な場合は、rootとして次のコマンドを実行します。

# touch /forcefsck

そして再起動してください。fsck安全のため、すべてのパーティションの操作が完了します。


ただし、LVMをルートデバイスとext3ファイルシステムとして使用しているため、オンラインで拡張できます。resize2fs始める前にインストールされていることを確認してください。そうでない場合は通常e2fsprogs。 (スペースが不足して設置できない場合は、整理してください/var/log。)

まず、次のように(ルートとして)プライマリボリュームを展開します。

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

(必要に応じてセクションを調整してください2G。これが追加するスペースの量です。)

次に、ファイルシステムのサイズを変更する必要があります。これは次の方法でオンラインで行うことができますresize2fs

# resize2fs /dev/mapper/HU-root

数秒/数分かかることがあります。邪魔しないでください。/forcefsck必要に応じて、最後にもう一度再起動するか、もう一度再起動します。必ずしも必要ではありませんが、常にそうします。

おすすめ記事