Question: I’ve got this [Dell XPS 15z](http://www.dell.com/us/business/p/xps-15z/pd) laptop laying around with a broken hard driving. I swapped the hard disk drive (same format) of another laptop for an SSD. So I thought I could try to make it work again by replacing the broken hard disk drive with this other hard disk drive which is still working.

Dell Laptop is working, I actually had it working with another hard disk drive on Ubuntu and Pear Linux.

But I need it on Windows 8 for a demo.

My spare hard disk drive, has already Windows 8 installed and if I were to put it back into my other laptop—a Vaio—it would boot and work properly.

But when I put that Windows 8 hard disk drive in my Dell XPS 15z I get the message 

> 
> Operating System Not Found
> 
> 
> 

I decided then I would try to reinstall Windows 8 with a USB bootable device [as explained here](http://windows.microsoft.com/en-US/windows-8/create-reset-refresh-media).

But when I boot from the USB device I get the error message again:

> 
> Operating System Not Found.
> 
> 
> 

I really don’t understand why this is not working.

PS: In the BIOS, I see the hard disk drive with it’s name and everything, so the BIOS is detecting it properly.

I tried to have a windows bootable usb, (OS running on key) when I boot in my usb flash drive, i have the same message again

Answer: 
If you put a script in `/etc/profile.d/`, it may run at startup, but only because `root` is active. If you do this, then if you run `su`, you may see that script start running again in your terminal. So, while this will run the script coincidentally at system start, it is not the system start that runs the script, but the activity of `root` that starts it.

If you want a script to run a true system startup, not just user login (including `root` login), then try a service. The advantage is that you can check its status with `systemctl status ...` Creating a service is not hard.

**Tweak, then paste this into your terminal** :

```bash
echo '[Unit]
Description=My amazing startup script

[Service]
Type=simple
ExecStart=/opt/path/to/myamazingstartup.sh

[Install]
WantedBy=multi-user.target' > /etc/systemd/system/myamazingstartup.service

chmod 755 /etc/systemd/system/myamazingstartup.service
systemctl enable myamazingstartup.service

# Now, `/opt/path/to/myamazingstartup.sh` will run at every startup. 

# Optional to start now:
systemctl start myamazingstartup

# Check how its running:
systemctl status myamazingstartup

```

* The `WantedBy=multi-user.target` part is mandatory, otherwise the `systemctl enable` will fail. The alternative setting is `graphical.target` and others. You can [read more here](https://unix.stackexchange.com/a/506374/315069).
* `Type=simple` is also mandatory
* Put your own information in:
	+ `Description=`
	+ `ExecStart=`

Voilà! You have a service that runs your script at startup and even allows you to check its status.
If you want your script to emit messages to the system log, use `logger` instead of `echo`.

```
#!/bin/bash
logger <<HERE
test
info
HERE
#exit  # Not really useful; the script will exit anyway

```