[LINUX] The story that had nothing to do with partitions when I did disk backup with dd for the first time

fs broken VM, I tried xfs_repair, but I'm scared if I don't backup? Because it was in a state, the story that backup studied

It's a very strange article because the original knowledge is that rather than being drunk.

When I first saw the console, it was in emergency mode. Ls / sysroot was empty with an error that / sysroot could not be mounted. When a genius colleague rebooted, he said he was able to boot in rescue mode.

What I learned for the first time this time. It seems that centos 7 has systemd.unit = rescue.target after pressing e when grub is selected. When I looked it up later, this was just a single user mode (for me). I heard the name rescue mode, but what was it just a single user mode?

rescue mode is equivalent to single user mode RHEL 10.3. WORKING WITH SYSTEMD TARGETS

That's the way I forgot my admin password when I was on Mac OS 10.1. It's the one that starts with cmd + s, right?

Aside from old tales, this is the name rescue ... but after all it's booted with / dev / sda so you can't xfs_repair the root partition, right? (Someone tell me) Isn't it completely different from rescue that starts with DVD or pxe? Is it okay to use the same words? Do you have different words?

It doesn't matter, but I couldn't rescue at all for a while because I typed res ** q ** ue.target. Reflection typo.

What i learned

Simply put, it's the one that's cool when emergency mode can't mount the root partition (probably the one that just boots with / boot or initramfs), and rescue.target is the one that forces it to boot with / def / sda. So I think that rescue.target cannot go if the root partition is bad in / etc / fstab. It seems that / dev / sdb cannot be mounted. (Tell me if anyone is right or wrong) No, wait, you're reading from the initramfs disk. Where is he?

Enter the main subject of a sloppy article.

The first moss story

I had 30GB of vm in my virtual box disk For the time being, I thought I should copy this in practice ...

Just fill it with 0 anyway, 8GB is fine, right? Add a disk with virtual box default = 8GB to the VM and make it / dev / sdb. I think I need a partition, so I create / dev / sdb1 with parted. After all xfs? That is, mkfs.xfs is already a habit here.

When you hit the dd command, that? Where are you copying? Is os running? Is it okay to have / dev / sda1 and / dev / sda2 and the important root partition under sda2, / dev / mapper / centos-root? that?


This is absolutely different, it's fundamentally wrong, but for the time being, I think this is also an experience

After dd if = / dev / mapper / centos-root of = / dev / sdb1, the mac became so heavy that it suddenly rebooted after a while.

A story that went well

Install centos7 with an 8GB disk that is easy to copy obediently. Obedient. Attach another 8GB disk and start rescue.target. Make sure it looks like / dev / sdb. And this simple and clear command.

dd if=/dev/sda of=/dev/sdb

You don't need to prepare a partition. Physical disk space? I'm going to do it. copy finished smoothly and shut down once. Detouch the original disk from the VM. Start with only the additional disk. You can use os normally. It means that all the partitions were duplicated together perfectly. Awesome. Is this dd? Awesome. Thank you for being able to imagine yourself from the first failure.

No, I learned a lot. dd It's really convenient! !!

How to see the progress of dd

You can see if you're still doing your best on iotop for the time being.

yum install -y iotop strace
# -Show only those running on o
iotop -o

Such kanji ↓ image.png

If it is strace, you can see what you are writing. However, if it is 100GB, a character string of 100GB or more will flow, so it is quite difficult to go over the NW. I saw that it would be nice to connect the tail, but it didn't work in my environment.

ps aux | grep dd #Get pid
strace -p 4458    #With pid as an argument
strace -p $PID | tail -n 5         #Show only last 5 lines (I don't work)

Recommended Posts

The story that had nothing to do with partitions when I did disk backup with dd for the first time
Code that I wish I had remembered when I participated in AtCoder for the first time (Reflection 1 for the next time)
A story that I had a hard time trying to create an "app that converts images like paintings" with the first web application
When writing to a csv file with python, a story that I made a mistake and did not meet the delivery date
For the time being, I want to convert files with ffmpeg !!
I tried to create serverless batch processing for the first time with DynamoDB and Step Functions
A story that didn't work when I tried to log in with the Python requests module
Impressions and memorandums when working with VS code for the first time
For the first time in Numpy, I will update it from time to time
What I did when I got stuck in the time limit with lambda python
Looking back on the machine learning competition that I worked on for the first time
A story that I was addicted to when I made SFTP communication with python
GTUG Girls + PyLadiesTokyo Meetup I went to machine learning for the first time
I tried using scrapy for the first time
How to use MkDocs for the first time
I played with Floydhub for the time being
I tried python programming for the first time.
I tried Mind Meld for the first time
Try posting to Qiita for the first time
A story that required preparation when trying to do a Django tutorial with plain centos7
I will try to summarize the links that seem to be useful for the time being
When I tried to do socket communication with Raspberry Pi, the protocol was different
I want to create a lunch database [EP1] Django study for the first time
What I did when I was angry to put it in with the enable-shared option
I want to create a lunch database [EP1-4] Django study for the first time
What I got into Python for the first time
I tried Python on Mac for the first time.
I tried python on heroku for the first time
For the first time, I learned about Unix (Linux).
AI Gaming I tried it for the first time
A story that I did not know how to load a mixin when making a front with the django app [Beginners learn python with a reference book in one hand]
I want to move selenium for the time being [for mac]
What I did to welcome the Python2 EOL with confidence
I tried the Google Cloud Vision API for the first time
The story that the private key is set to 600 with chmod
I want to create a Dockerfile for the time being.
If you're learning Linux for the first time, do this!
A story that I had a hard time displaying graphs on top of each other with matplotlib
The story of returning to the front line for the first time in 5 years and refactoring Python Django
What I did when I migrated to Linux 2 with EOL support for Amazon Linux (learning and failure stories)
When I cut the directory for UNIX Socket under / var / run with systemd, I got stuck in a pitfall and what to do
Kaggle for the first time (kaggle ①)
Kaguru for the first time
I tried to describe the traffic in real time with WebSocket
Differences C # engineers felt when learning python for the first time
The story that the guard was confined when the laboratory was converted to IoT
What to do when you get "I can't see the site !!!!"
A memo when creating an environment that can be debugged with Lambda @ Edge for the time being
How to write what to do when an application is first displayed in Qt for Python with Designer
[Hi Py (Part 1)] I want to make something for the time being, so first set a goal.
Parsing PDFs, including text, is easy with Python ... I had a time when I was thinking that way.
For the time being using FastAPI, I want to display how to use API like that on swagger
Summary of sites and learning procedures that will be helpful for those who are trying to make games with pygame for the first time