나는 이것을 가지고있다:
###########################
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 20G 2.1G 17G 12% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 34M 1.9G 2% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
###########################
# fdisk -l
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00044686
Device Boot Start End Blocks Id System
/dev/sda1 * 4096 40962047 20478976 83 Linux
/dev/sda2 40962048 42008575 523264 82 Linux swap / Solaris
###########################
# mount
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=2009752k,nr_inodes=502438,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=27,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
###########################
(parted) print
Model: ATA HGST HUS724020AL (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 2097kB 21.0GB 21.0GB primary ext4 boot
2 21.0GB 21.5GB 536MB primary linux-swap(v1)
보시다시피 2Tb HDD는 루트용 20Gb와 스왑용으로 조금 더 나누어져 있습니다. 모든 서비스를 설치하고 구성한 후 이 문제를 발견했습니다... 이제 주 파티션을 확장하고 싶습니다. 나는 나머지 공간을 그 안에 집어넣고 싶지 않습니다 /home
. 은(는) 특정 작업을 수행하는 소규모 프로덕션 서버이므로 기본 파티션에 모든 공간을 확보하고 싶습니다.
문제는 구글에 검색해보니 "라이브 CD 사용"이나 "복구 모드로 부팅"밖에 나오지 않는데 그게 안되고 일만 통과해서 ssh
다 잃어버릴까봐 걱정됩니다. 내 데이터를 다시 설치하고 다시 설치해야 하므로 모든 것을 구성해야 하므로 작업을 시작하기 전에 모든 것을 물어보고 망치는 것을 선호합니다.
답변1
글쎄, 나는 성공했다. 구체적인 방법은 다음과 같습니다.
스왑 파티션 삭제
# swapoff /dev/sda2
그런 다음 시작하십시오 fdisk
.
# fdisk /dev/sda
Start
첫 번째 파티션의 열을 고려하여 파티션 정보를 나열합니다 .
Command (m for help): p
Device Boot Start End Blocks Id System
/dev/sda1 * 4096 47029167 1903512536 83 Linux
/dev/sda2 47029168 57029167 50000000 83 Linux
두 개의 파티션을 삭제합니다.
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 1 has been deleted.
Command (m for help): d
Partition number (1): 1
Partition 1 has been deleted.
Start (4096)
새로운 크기로 새 파티션을 생성했지만 기본 파티션으로 시작했습니다.
Command (m for help): n
Select (default p): p
Partition number (1, default 1): 1
First sector (2048-3907029167, default 2048): 4096 //Important. Notice that is not the same as the default (in my case).
Last sector (default 3907029167): 3807029167 //I've put less to have spare space for partition 2
Command (m for help): n
Select (default p): p
Partition number (2, default 2): 2
First sector (2048-3907029167, default 2048): 3807029168 //Important. Notice that starts with 20148 because is the first empty space detected, but in reality I want it AFTER the first partition, so I've put another number (in my case).
Last sector (default 3907029167): 3907029167
Boot
그런 다음 플래그를 설정했습니다 sda1
.
Command (m for help): a
Partition number (1,2, default 2): 1
그런 다음 재부팅하고 실행합니다(재부팅 후).
# resize2fs /dev/sda1
그러면 모든 것이 괜찮습니다.
################################
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.8T 2.1G 1.7T 1% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 9.5M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
################################
# fdisk -l
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00044686
Device Boot Start End Blocks Id System
/dev/sda1 * 4096 3807029167 1903512536 83 Linux
/dev/sda2 3807029168 3907029167 50000000 83 Linux
이제 교환을 다시 생성하고 완료해야 합니다.