群晖NAS不丢失数据重装系统

本文介绍了如何通过SSH登录群晖NAS,使用`dd`和`fdisk`命令安全地重置硬盘,同时保留数据。首先,通过SSH以管理员身份登录,清空硬盘数据但不破坏数据分区。然后,使用`fdisk`删除QTS操作系统分区,重启后手动设置并保留原有数据。最后,重新启用Microsoft Networking,即可在新安装的QTS系统中找到原有数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Quickly Reset the Hard Disk in your QNAP Device as New

In the next few months, I am going to port  ZurmoCRM  onto  QNAP . I might need to test different configuration and need to reinstall  QTS  several times. Remove the hard disk and use SATA to USB bridge to kill partition takes too much time. Instead, you may  SSH  to login, then clean  QTS  partition with  dd . or remove with  fdisk .

Login to QNAP with SSH

ssh-keygen -R 10.42.0.12 -f /home/amigo/.ssh/known_hosts

Remove RSA key with previous QTS if necessary. Please use your NAS IP to replace 10.42.0.12, and user home directory for /home/amigo.

ssh admin@10.42.0.12

Login as admin which is the same as your web admin account and password.

Fill Null to Disk

df

List of free disk of mounted device to identify the device name of your hard drive in NAS.

dd if=/dev/zero of=/dev/sda bs=10M count=10

/dev/zero is a special file with null characters only. Used as source as a character stream for initializing data storage.
bs=10M means read and write up to 10M bytes at a time.
count=10 means repeat for 10 input blocks.
It will write 10M * 10 data to the beginning of /dev/sda which shall destroy QTS.

Then reboot with reboot command. Now, it shall reinstall QTS firmware automatically.

Remove QTS Partition and Keep Data

There is an alternative and better solution to keep your data which stores in another partition. Instead of dd, use fdisk to work on partition directly.

First to check what is available in disk. Here is a sample executing fdisk -p /dev/sdafrom my QNAP TS-112.

[/sbin] # fdisk -p /dev/sda     

Disk /dev/sda: 2000.3 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          66      530125   83  Linux
/dev/sda2              67         132      530142   83  Linux
/dev/sda3             133      243138  1951945693   83  Linux
/dev/sda4          243139      243200      498012   83  Linux

-p to display partition in a disk.
/dev/sda is the disk name.

Then delete QTS partition by executing fdisk -d 1 /dev/sda.

[/sbin] # fdisk -d 1 /dev/sda
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

-d 1 to delete the first partition.
/dev/sda is the disk name.

Then reboot with reboot command. After reboot, it will prompt to install QTSfirmware. Choose [Manual Setup], and click on [Configure disks later] in [Disk] step. It will automaticall to apply settings and reboot.

After reboot, login to QNAP device, re-enable [Microsoft Networking]. Now, you may see your data in the same folder before re-install QTS.

Reference

  1. ZurmoCRM
  2. QNAP
  3. QNAP: QTS 4.0
  4. Wiki: Secure Shell
  5. LinuxQuestions.org: Fdisk
  6. Wiki: df (Unix)
  7. Wiki: dd (Unix)
  8. Wiki: /dev/zero
  9. Mobile01: 從零開始 – 如何重新安裝 QNap NAS 作業系統
  10. QNAP TS-112

转载于:https://my.oschina.net/CasparLi/blog/330369

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值