REGZAのUSB HDDをコピーしつつ交換する4TB

REGZA Z8のUSB HDDの内容を1TB→4TBへ移植する。Debian10編

今回はBigSectorにあわせてパーティションを作成したいのでLinuxでパーティションを作りたい。そして容量も拡張したい。

概要

partedでBigSectorにあわせたパーティション作成、xfs_copyでファイルシステムコピー、xfs_growでファイルシステム拡張、xfs_adminでUUID移植でOK。

ディスク配置

  • /dev/sdc1 (旧HDD)
  • /dev/sdb1 (新HDD)

手順

Regzaにつないで初期化

GPTなので大容量もいけそう。

新HDDのパーティションを作成する(parted)

BigSectorなのでAlignmentをあわせる。

root@ange:/home/tishi# /sbin/parted /dev/sdb                              
sh: 1: dmidecode: not found
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) rm                                                               
Partition number? 1                                                       
(parted) mkpart
Partition name?  []? primary                                              
File system type?  [ext2]? xfs                                            
Start? 1M                                                                 
End? 100%                                                                 
(parted) align-check                                                      
alignment type(min/opt)  [optimal]/minimal?                               
Partition number? 1                                                       
1 aligned
(parted) p                                                                
Model: WD Elements 25A1 (scsi)
Disk /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  4001GB  4001GB  xfs          primary

(parted) quit                                                             
Information: You may need to update /etc/fstab.

root@ange:/home/tishi# /sbin/mkfs.xfs -f /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=244186432 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=0
data     =                       bsize=4096   blocks=976745728, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=476926, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

root@ange:/home/tishi# 

ファイルシステムコピー (xfs_copy)

root@ange:/home/tishi# date; /usr/sbin/xfs_copy /dev/sdc1 /dev/sdb1 ; date
2020年  8月 16日 日曜日 11:06:01 JST
 0%  ... 10%  ... 20%  ... 30%  ... 40%  ... 50%  ... 60%  ... 70%  ... 80%  ... 90%  ... 100%

All copies completed.
2020年  8月 16日 日曜日 13:17:17 JST
root@ange:/home/tishi# 

ファイルシステムサイズ拡張 (xfs_growfs)

root@ange:/home/tishi# mount -t xfs /dev/sdb1 /mnt
root@ange:/home/tishi# df -k
ファイルシス   1K-ブロック      使用    使用可 使用% マウント位置
udev               4024260         0   4024260    0% /dev
tmpfs               808816     83192    725624   11% /run
/dev/sda1         19728044  16291512   2411364   88% /
tmpfs               393216         0    393216    0% /dev/shm
tmpfs                 5120         4      5116    1% /run/lock
tmpfs              4044068         0   4044068    0% /sys/fs/cgroup
/dev/sda2        103081248   7121372  90700616    8% /home
tmpfs               808812         4    808808    1% /run/user/119
/dev/shm            393216         4    393212    1% /tmp
tmpfs               808812         0    808812    0% /run/user/11281
tmpfs               808812         0    808812    0% /run/user/11280
/dev/sdb1        976285612 715258992 261026620   74% /mnt
root@ange:/home/tishi# /usr/sbin/xfs_growfs /mnt
meta-data=/dev/sdb1              isize=256    agcount=4, agsize=61047659 blks
         =                       sectsz=512   attr=2, projid32bit=0
         =                       crc=0        finobt=0, sparse=0, rmapbt=0
         =                       reflink=0
data     =                       bsize=4096   blocks=244190636, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=0
log      =internal log           bsize=4096   blocks=119233, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 244190636 to 976745728
root@ange:/home/tishi# df -k
ファイルシス   1K-ブロック      使用     使用可 使用% マウント位置
udev               4024260         0    4024260    0% /dev
tmpfs               808816     83192     725624   11% /run
/dev/sda1         19728044  16291512    2411364   88% /
tmpfs               393216         0     393216    0% /dev/shm
tmpfs                 5120         4       5116    1% /run/lock
tmpfs              4044068         0    4044068    0% /sys/fs/cgroup
/dev/sda2        103081248   7121372   90700616    8% /home
tmpfs               808812         4     808808    1% /run/user/119
/dev/shm            393216         4     393212    1% /tmp
tmpfs               808812         0     808812    0% /run/user/11281
tmpfs               808812         0     808812    0% /run/user/11280
/dev/sdb1       3906505980 715259568 3191246412   19% /mnt
root@ange:/home/tishi# umount /mnt
root@ange:/home/tishi# 

UUIDを移植 (xfs_admin)

旧HDD(/dev/sdc1)のUUIDを新HDD(/dev/sdb1)のHDDへ移植する。

root@ange:/home/tishi# /usr/sbin/xfs_db /dev/sdb1
xfs_db> uuid
UUID = 6f6ec555-62fb-4744-9b55-6daec57e8a76
xfs_db> quit
root@ange:/home/tishi# /usr/sbin/xfs_db /dev/sdc1
xfs_db> uuid
UUID = 9d58094b-0380-4a8b-8254-8846e96d82ef
xfs_db> quit
root@ange:/home/tishi# 

root@ange:/home/tishi# /usr/sbin/xfs_db -x /dev/sdb1
xfs_db> uuid 9d58094b-0380-4a8b-8254-8846e96d82ef
Clearing log and setting UUID
writing all SBs
new UUID = 9d58094b-0380-4a8b-8254-8846e96d82ef
xfs_db> quit
root@ange:/home/tishi# 

そのほか

参考