
파티션을 디스크의 시작 부분으로 조금 이동하는 방법은 무엇입니까? Parted는 어떤 이유에서든 파일 시스템을 원합니다(이유는 모르겠습니다). 모든 섹터를 왼쪽으로 이동하고 싶습니다...
r@l:15:32:45:~# parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: HGST HTS 541010A9E680 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 32.2GB 32.2GB primary fat32
2 32.2GB 37.6GB 5360MB primary
3 37.6GB 1000GB 963GB primary
(parted) move 3
WARNING: you are attempting to use parted to operate on (move) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs. We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Error: Could not detect file system.
답변1
sfdisk
, 스크립팅 가능한 fdisk가 되려는 목적으로 일부 버전부터 --move-data
옵션이 있습니다. 예그들의 맨 페이지:
echo '+100M,' | sfdisk --move-data /dev/sdc -N 1
답변2
dd 및 fdisk를 사용한 수동 방법:
# fdisk -l /dev/sdb | grep sdb3
/dev/sdb3 73402368 1953525167 940061400 83 Linux
# fdisk /dev/sdb
Command (m for help): d
Partition number (1-4): 3
Command (m for help): n
Partition number (1-4, default 3): 3
First sector (73385984-1953525167, default 73385984):
Using default value 73385984
Last sector, +sectors or +size{K,M,G} (73385984-1953525167, default 1953525167):
Using default value 1953525167
Command (m for help): w
The partition table has been altered!
# fdisk -l /dev/sdb | grep sdb3
/dev/sdb3 73385984 1953525167 940069592 83 Linux
# dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 count=100 skip=$((73402368-73385984)) seek=0 2> /dev/null | file -s -
/dev/stdin: LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f
# dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 skip=$((73402368-73385984)) seek=0 of=/dev/sdb3
# file -s /dev/sdb3
/dev/sdb3: sticky LUKS encrypted file, ver 1 [aes, cbc-essiv:sha256, sha1] UUID: af1c47f0-4ca5-4ea7-a091-065bd263653f
이제 약 2시간을 기다리고 있습니다. (더 많은 것은 18시간처럼 보입니다...)
참고: 이는 데이터를 앞으로 이동하지 않고 뒤로만 이동합니다.
일시중지:
# pidof dd
907
# kill -STOP 907
# cat /proc/907/fdinfo/1
pos: 586921398272
flags: 0100001
# kill -9 907
remember 586921398272/512 = 1146330856
재개:
dd conv=notrunc bs=512 iflag=fullblock if=/dev/sdb3 skip=$((1146330856+73402368-73385984)) seek=1146330856 of=/dev/sdb3
답변3
항상 사용할 수 있습니다 dd
.
- liveCD에서 부팅(또는 파티션이 마운트되지 않도록 하는 다른 방법)
dd if=/dev/sdc2 of=somefile bs=1M
파일에 파티션 복사본을 만듭니다.- 파티션을 삭제하려면 fdisk(또는 원하는 대로)
- fdisk(또는 원하는 것)를 사용하여 원하는 위치에 파티션을 만듭니다.
dd of=/dev/sdc2 if=somefile bs=1M
파일의 내용을 복원합니다.